IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > EntityQueryFilterCollection Class > AddFilter Method : AddFilter<T>(Func<IQueryable<T>,IQueryable<T>>,Boolean) Method |
'Declaration
Public Overloads Sub AddFilter(Of T As Class)( _ ByVal transformFunc As Func(Of IQueryable(Of T),IQueryable(Of T)), _ Optional ByVal canReplaceIfAlreadyExists As Boolean _ )
'Usage
Dim instance As EntityQueryFilterCollection Dim transformFunc As Func(Of IQueryable(Of T),IQueryable(Of T)) Dim canReplaceIfAlreadyExists As Boolean instance.AddFilter(Of T)(transformFunc, canReplaceIfAlreadyExists)
public void AddFilter<T>( Func<IQueryable<T>,IQueryable<T>> transformFunc, bool canReplaceIfAlreadyExists ) where T: class
Exception | Description |
---|---|
System.ArgumentException | Thrown if a filter for the entity type is already in the collection and the canReplaceIfAlreadyExists paremter is set to false |
public void FilteringSample() { // Query for all customers. A filter will be applied prior to execution. var mgr = new DomainModelEntityManager(); var list = mgr.Customers.ToList(); } // Server-side implementation of EntityServerQueryInterceptor public class EntityServerQueryManager : EntityServerQueryInterceptor { protected override bool FilterQuery() // Add filters QueryFilters.AddFilter<Customer>(q => q.Where(c => c.Country == "USA")); QueryFilters.AddFilter<Employee>(q => q.Where(e => e.Country == "USA")); return true; } }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2